const cai = wx.cloud.database().collection("cai")
Page({
  data: {
    rank: [],
    hello: 0
  },
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
    })
    this.getcai();
    wx.hideLoading()
  },
  gotodetail(e) {
    wx.navigateTo({
      url: '/pages/detail/detail?id=' + e.currentTarget.dataset.index._id,
    })
  },
  getcai() {
    let that = this
    wx.cloud.callFunction({
      name: "getdatabase",
      success: (res) => {
        if (res) {
          this.setData({
            rank: res.result.data.slice(0, 10),
          })
          console.log(this.data.rank)
        }
      }
    })

  },
  gotourl(value) {
    let url = value.currentTarget.dataset.index
    if (url == 3) {
      wx.navigateTo({
        url: '/pages/whatsthis/whatsthis',
      })
    }
    if (url == 2) {
      wx.navigateTo({
        url: '/pages/feedback/feedback',
      })
    }
    if (url == 4) {
      wx.navigateTo({
        url: '/pages/mystar/mystar',
      })
    }
    if (url == 5) {
      wx.showModal({
        title: '提示',
        content: '请选择校区',
        confirmText:"学院路",
        cancelText:"沙河",
        confirmColor:"#000000",
        success(res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/touzi/touzi?id='+ "1"
            })
          } else if (res.cancel) {
            wx.navigateTo({
              url: '/pages/touzi/touzi?id='+ "2"
            })
          }
        }
      })
      
    }
  }
})